//
//  StatusCellBottomView.m
//  weibo-OC
//
//  Created by diyuyma on 16/3/20.
//  Copyright © 2016年 zhangkaiyun. All rights reserved.
//

#import "StatusCellBottomView.h"
#import "TempViewController.h"
#import "Masonry.h"

#define w 0.5
#define scale 0.4

@interface StatusCellBottomView ()
@property (nonatomic, strong)UIButton *retweetedBtn;
@property (nonatomic, strong)UIButton *composeBtn;
@property (nonatomic, strong)UIButton *likeBtn;
@end

@implementation StatusCellBottomView

- (void)retweetedBtnDidClcik {
    TempViewController *temp = [[TempViewController alloc] init];
    [self.retweetedBtn.NavController pushViewController:temp animated:true];
}

// MARK: 3.重写父类的构造方法 调用设置 UI
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    self.backgroundColor = [UIColor colorWithWhite:0.98 alpha:1];
    [self setupUI];
    return self;
}


// MARK: 2.设置 UI
- (void)setupUI {
    // 添加子控件
    [self addSubview:self.retweetedBtn];
    [self addSubview:self.composeBtn];
    [self addSubview:self.likeBtn];
    // 设置约束
    [self.retweetedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.top.equalTo(self.mas_top);
        make.height.equalTo(self.mas_height);
    }];
    
    UIView *sepView1 = [self sepView];
    [self addSubview:sepView1];
    [sepView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.retweetedBtn.mas_right);
        make.height.equalTo(self.retweetedBtn.mas_height).multipliedBy(scale);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(w);
    }];

    [self.composeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.retweetedBtn.mas_right);
        make.top.mas_equalTo(self.mas_top);
        make.height.mas_equalTo(self.mas_height);
        make.width.equalTo(self.retweetedBtn.mas_width);
    }];

    UIView *sepView2 = [self sepView];
    [self addSubview:sepView2];
    [sepView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.composeBtn.mas_right);
        make.height.equalTo(self.retweetedBtn.mas_height).multipliedBy(scale);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(w);
    }];

    
    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.composeBtn.mas_right);
        make.top.mas_equalTo(self.mas_top);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(self.mas_height);
        make.width.mas_equalTo(self.composeBtn.mas_width);
    }];
    
    // 添加点击事件
    [self.retweetedBtn addTarget:self action:@selector(retweetedBtnDidClcik) forControlEvents:UIControlEventTouchUpInside];
}

// MARK: 1.懒加载所有子控件
- (UIButton *)retweetedBtn {
    if (_retweetedBtn == nil) {
        _retweetedBtn = [[UIButton alloc] init];
        [_retweetedBtn  initWithTitle:@"转发" WithBackImage:nil WithColor:[UIColor darkGrayColor] WithImage:@"timeline_icon_retweet" WithSize:10];
    }
    return _retweetedBtn;
}

- (UIButton *)composeBtn {
    if (_composeBtn == nil) {
        _composeBtn = [[UIButton alloc] init];
        [_composeBtn  initWithTitle:@"评论" WithBackImage:nil WithColor:[UIColor darkGrayColor] WithImage:@"timeline_icon_comment" WithSize:10];
    }
    return _composeBtn;
}

- (UIButton *)likeBtn {
    if (_likeBtn == nil) {
        _likeBtn = [[UIButton alloc] init];
        [_likeBtn  initWithTitle:@"赞" WithBackImage:nil WithColor:[UIColor darkGrayColor] WithImage:@"timeline_icon_unlike" WithSize:10];
    }
    return _likeBtn;
}

- (UIView *)sepView {
     UIView *sepView = [[UIView alloc] init];
        sepView.backgroundColor = [UIColor darkGrayColor];
    return sepView;
}
@end
